package cn.wolfcode.user.servlet;

import cn.wolfcode.user.domain.User;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/logout")
public class LogOutServlet extends HttpServlet {


    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
//        req.setCharacterEncoding("utf-8");
//        resp.setCharacterEncoding("utf-8");
//        User user = (User) req.getSession().getAttribute("USER_IN_SESSION");
//        Cookie cookie = new Cookie("username",user.getUsername() );
        req.getSession().removeAttribute("USER_IN_SESSION");
        resp.sendRedirect("/login.jsp");
    }
}
